package baidu.reader.txt.ui
{
    import baidu.reader.common.*;
    import baidu.reader.common.model.*;
    import baidu.reader.common.ui.*;
    import baidu.reader.txt.model.*;
    import baidu.ui.controls.*;
    import baidu.ui.managers.*;
    import flash.events.*;
    import flash.text.*;

    public class TxtBookPageBase extends BookPageBase
    {
        protected var screenModel:ScreenModel;
        protected var chapterModel:TxtChapterModel;
        protected var preferenceModel:AppPreferenceModel;
        protected var nextChapterButton:Button;

        public function TxtBookPageBase()
        {
            this.initButton();
            return;
        }

        protected function initButton() : void
        {
            this.nextChapterButton = new Button();
            this.nextChapterButton.setStyle("skin", ResourceFactory.NextButtonSkin);
            this.nextChapterButton.useHandCursor = true;
            this.nextChapterButton.drawNow();
            this.nextChapterButton.addEventListener(MouseEvent.CLICK, this.nextChapClickHandler);
            return;
        }

        protected function nextChapClickHandler(event:MouseEvent) : void
        {
            dispatchEvent(new ReaderEvent(ReaderEvent.GO_NEXT_CHAPTER));
            return;
        }

        override protected function initModel() : void
        {
            this.chapterModel = InstanceManager.createSingletonInstance(TxtChapterModel);
            this.chapterModel.addEventListener(Event.COMPLETE, this.dataCompleteHandler);
            this.screenModel = InstanceManager.createSingletonInstance(ScreenModel);
            this.screenModel.addEventListener(Event.RESIZE, this.screenResizeHandler);
            this.preferenceModel = InstanceManager.createSingletonInstance(AppPreferenceModel);
            return;
        }

        public function enableModelUpdate() : void
        {
            this.initModel();
            return;
        }

        public function disableModelUpdate() : void
        {
            this.chapterModel.removeEventListener(Event.COMPLETE, this.dataCompleteHandler);
            this.screenModel.removeEventListener(Event.RESIZE, this.screenResizeHandler);
            return;
        }

        protected function screenResizeHandler(event:Event) : void
        {
            return;
        }

        protected function dataCompleteHandler(event:Event) : void
        {
            this.addPageContent();
            return;
        }

        protected function addPageContent() : void
        {
            return;
        }

        public function setTextFormat(param1:TextFormat) : void
        {
            return;
        }

        public function getCurrentFirstCharIndex() : int
        {
            return 0;
        }

        public function getSecondLineFirstCharIndex() : int
        {
            return 0;
        }

        public function get scrollPercent() : Number
        {
            return 0;
        }

    }
}
